<template>
    <div class="menu-list" >
                        <div v-for="item in pickedup" :key="item.id">
                            <div class="time" >
                                <span>2023-2-6</span>
                                <span>交易成功&nbsp;&nbsp;|&nbsp;&nbsp;<van-icon name="delete-o"  @click="deleteGoods(item.id)"/></span>
                            </div>
                            <div  >
                                <van-card num="2" :price="item.price" desc="02月10日提货" :title="item.shop"
                                    :thumb="item.picture" @click="todetail(item.id)">
                                    <template #footer>
                                    </template>
                                </van-card>
                                <van-button round color="#ED0D5B" plain size="small"
                                    type="danger" @click="comment">记得好评</van-button>
                            </div>
                            <hr>
                        </div>
   </div>
</template>

<script setup lang="ts">
import {type Ref ,ref,onMounted} from 'vue'
import { usePyStore } from '@/stores/pyok';
import {useRouter} from 'vue-router'

const router = useRouter()
const usepyok = usePyStore()
const pickedup:Ref<Array<any>> = ref([])
// 遍历对象 返回一个新的数组

const time1=setTimeout(() => {
    pickedup.value = usepyok.list.map(item=>item)
},5000);
// 删除
const deleteGoods =(id:number)=>{
    const index = pickedup.value.findIndex(item=>item.id==id)
    pickedup.value.splice(index,1)  
    console.log(pickedup.value);
}
// 商品详情
const todetail = (id:number)=>{
    router.push({path:'/detail',query:{id}})
} 
// 好评
const comment =()=>{
    router.push({path:'/comment'})
}
onMounted(()=>{
    time1
})

</script>

<style scoped lang="scss">
.menu-list {
    margin-top: 10px;
    width: 100%;
    display: flex;
    justify-content: space-around;
    flex-direction: column;

    .time {
        padding: 5px 24px 5px 24px;
        display: flex;
        justify-content: space-between;
        background-color: #ffffff;

    }

    .time2 {
        padding: 5px 24px 5px 24px;
        display: flex;
        justify-content: space-between;
        background-color: #ffffff;

        .redsapn {
            color: red;
        }
    }
    .van-button{
        float: right;
    }
}
</style>